package com.fw.application.controller.open;

import com.fw.mes.Result;
import com.fw.utils.AliUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import static com.fw.mes.ResultUtils.success;

/**
 * @Author:yanwei
 * @Date: 2020/10/19 - 14:18
 */
@CrossOrigin
@RestController
@RequestMapping("/web/core")
@Api(tags = "公众接口- 例如文件上传")
public class CoreController {


    @SneakyThrows
    @PostMapping("/uploadImage")
    @ApiOperation(value = "文件上传:data = imageUrl")
    public Result<String> uploadImage(@RequestPart("file") MultipartFile multipartFile) {
        return success(AliUtil.uploadImage(multipartFile.getInputStream(), multipartFile.getOriginalFilename()));
    }

    @SneakyThrows
    @PostMapping("/uploadMp4")
    @ApiOperation(value = "文件上传:data = imageUrl")
    public Result<String> uploadMp4(@RequestPart("file") MultipartFile multipartFile) {
        return success(AliUtil.uploadMp4(multipartFile.getInputStream(), multipartFile.getOriginalFilename()));
    }


}
